﻿#define _CRT_SECURE_NO_WARNINGS
#include<string>
#include<iostream>
#include<utility>
#include"BinarySeacherTree.h"
using namespace std;

//int main()
//{
//	vector<int> arr({321,123,213,3,645,43,21});
//	BinarySeacherTree<int,int> tree;
//	for (auto& ch : arr)
//	{
//		tree.Insert(ch, 1);
//	}
//
//	/*BinarySeacherTree<int, int>::Node* ret = tree.Find(21);
//	if(ret)
//	cout << ret->key << " " << ret->val<<endl;*/
//
//	tree.InOrder();
//	cout << endl;
//	for (auto& ch : arr)
//	{
//		tree.Erase(ch);
//		tree.InOrder();
//		cout << endl;
//	}
//	return 0;
//}

void TestBSTree()
{
	/*BinarySeacherTree<string, string> dict;
	dict.Insert("insert", "插入");
	dict.Insert("erase", "删除");
	dict.Insert("left", "左边");
	dict.Insert("string", "字符串");

	string str;
	while (cin >> str)
	{
		auto ret = dict.Find(str);
		if (ret)
		{
			cout << str << ":" << ret->val << endl;
		}
		else
		{
			cout << "单词拼写错误" << endl;
		}
	}*/

	string strs[] = { "苹果", "西瓜", "苹果", "樱桃", "苹果", "樱桃", "苹果", "樱桃", "苹果" };
	// 统计水果出现的次
	BinarySeacherTree<string, int> countTree;
	for (auto str : strs)
	{
		auto ret = countTree.Find(str);
		if (ret == NULL)
		{
			countTree.Insert(str, 1);
		}
		else
		{
			ret->val++;
		}
	}
	countTree.InOrder();
	BinarySeacherTree<string, int> count(countTree);
	cout << endl;
	BinarySeacherTree<string, int> count2;
	count2 = count;
	count2.InOrder();
	cout << endl;
	count.InOrder();
}
int main()
{
	TestBSTree();
	return 0;
}


